package com.example.compose.timer


import androidx.compose.foundation.layout.height
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.PlayArrow
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.compose.ui.theme.ComposeTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MyTopAppBar(
    isRunning: Boolean,
    onStartClicked: () -> Unit,
    onResetClicked: () -> Unit
) {
    TopAppBar(
//        modifier = Modifier.height(70.dp),
        title = {
            Text(text = "标题")
        },
        navigationIcon = {
            IconButton(
                onClick = if (isRunning) onResetClicked else onStartClicked,
            ) {
                Icon(
                    imageVector = if (isRunning) Icons.Filled.Close else Icons.Default.PlayArrow,
                    contentDescription = ""
                )
            }
        },
        actions = {

        }
    )
}


@Preview
@Composable
private fun MyTopAppBarPreview() {
    ComposeTheme {
        MyTopAppBar(isRunning = false, onStartClicked = { /*TODO*/ }) {

        }
    }
}